﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CooStationsToolsCore.common
{
    /// <summary>
    /// 公用静态常量
    /// </summary>
    public class Constants
    {
        /// <summary>
        /// 程序所在文件目录
        /// </summary>
        public static string proPath = AppDomain.CurrentDomain.BaseDirectory;


        /// <summary>
        /// 随机ID
        /// </summary>
        /// <returns></returns>
        public static string GetRandom()
        {
            string guid = Guid.NewGuid().ToString();
            int n = guid.IndexOf("-");
            string result = guid.Substring(0, n) + DateTime.Now.Ticks;
            return result;
        }

        /// <summary>
        /// 检查中文字符
        /// </summary>
        /// <param name="inputString"></param>
        /// <returns></returns>
        public static bool IsChineseLetter(string inputString)
        {
            int code = 0;
            int chfrom = Convert.ToInt32("4e00", 16);    //范围（0x4e00～0x9fff）转换成int（chfrom～chend）
            int chend = Convert.ToInt32("9fff", 16);
            if (inputString != "")
            {
                for (int i = 0; i < inputString.Length; i++)
                {
                    code = Char.ConvertToUtf32(inputString, i);    //获得字符串input中指定索引index处字符unicode编码

                    if ((code >= chfrom && code <= chend) || code == ' ')
                    {
                        return true;     //当code在中文范围内返回true
                    }
                    else
                    {
                        //当code不在中文范围内返回false
                    }
                }
            }
            return false;
        } 
        public static LogManager logManager = new LogManager();

    }
}
